package cn.wolfcode.luowowo.test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;


public class Tdgag {
    @Autowired
    private RedisTemplate template;

    public static void main(String[] args) {
        List<Long> list = new ArrayList<>();
        list.add(1L);
        list.add(10L);
        list.add(5L);
        list.add(8L);
        list.add(15L);
        list.add(21L);
        list.add(12L);
        for (Long num : list) {
            System.out.println(num);
        }
        Collections.sort(list, new Comparator<Long>() {
            public int compare(Long o1, Long o2) {
                Long ret = o2 - o1;
                return ret.intValue();
            }

        });
        if (list.size() > 4) {
            list = list.subList(0, 4);
        }
        System.out.println("排序");
        for (Long num : list) {
            System.out.println(num);
        }

    }
}
